package master;

/**
 * @author chenyw
 * @date 2022/8/30 11:20
 */
public class M153findMin {
    public int findMin(int[] nums) {
        int n = nums.length;
        if (n == 1) {
            return nums[0];
        }
        int left = 0;
        int right = n - 1;
        int min = Integer.MAX_VALUE;
        while (left < right) {
            int mid = (left + right) / 2;
            if (nums[mid] > nums[left]) {
               if (nums[left] < nums[right]) {
                   return nums[left];
               }
               left = mid + 1;
            } else {
                left += 1;
            }
        }
        return nums[left];
    }

}
